package com.example.idie.bean;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Setter;

@Setter
public class User {
    @TableId(type = IdType.AUTO)
    private Integer userId;
    private String username;

    private Integer usertype;
    private String password;
    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int setUserType(Integer userType) {return this.usertype = userType;}

    public int getUserType() {return this.usertype;}

    //    通过用户类型得到用户角色，只有三种用户：管理员、普通用户，专业用户
    public String getUserRole() {
        if (this.usertype == 1) {
            return "admin";
        }
        else if (this.usertype == 2) {
            return "ordinary";
        }
        else {
            return "profession";
        }
    }

//    public User(Integer userId, String username, String password) {
//        this.userId = userId;
//        this.username = username;
//        this.password = password;
//    }
//
//    public User() {
//    }

    public Integer getUserId() {
        return userId;
    }

    public String getUsername() {
        return username;
    }

    public boolean validatePassword(String password) {
        if (this.password.equals(password)) {
            return true;
        } else {
            return false;
        }
    }
    public boolean validateUserType(Integer usertype) {
        System.out.println(this.usertype);
        System.out.println(usertype);
        if (this.usertype.equals(usertype)) {
            return true;
        }
        return false;
    }
}
